<?php
	if($featured_post) {
		$temp = 1;
		foreach ($featured_post as $key => $value) {
		// for ($i=0; $i < sizeof($featured_post); $i++) { 
			if ($temp <= 4) {
				// $image = CHtml::image(Yii::app()->request->baseUrl.'/images/Product/'.$value->image_link,"image",array("width"=>200));
				echo '<div class="featured-post-typical_'.($temp%2).'">';
				echo CHtml::image(Yii::app()->request->baseUrl.'/images/Product/'.$value->image_link,"image",array("width"=>180, "height"=>112));
                echo '<div class="featured-container">';
                echo '<h3>';
                echo '<p style="margin-bottom:5px;"><strong>'.CHtml::link($value->post_title,array('post/'.$value->id),array('class'=>'post-title', 'alt'=>$value->post_title)).'</strong></p>';
                echo '<span style="font-size: 11px;">Ngày viết: '.date("H:i d-m-Y", strtotime($value->created)).'</span>';
                echo '</h3>';
				echo '<div class="featured-content">';
				
				if(strlen($value->post_content) < 180) {
					echo $value->post_content;
				} else {
					$newCut = substr($value->post_content, 0, 180);
					$newShort = substr($newCut, 0, strrpos($newCut, ' '));
					echo $newShort.' ...';
				}

				echo '</div>';
				echo '</div></div>';
			}else {
				echo '<div class="featured-post-related">';
				if ($temp == 5) { echo '<h4>Bài viết khác</h4>';}
				echo '<h5> ✎	'.CHtml::link($value->post_title,array('post/'.$value->id),array('class'=>'title1')).'.</h5>';
				echo '</div>';
			}
			$temp ++;
		}
	}
?>